//
//  CardView.m
//  YSLDraggingCardContainerDemo
//
//  Created by yamaguchi on 2015/11/09.
//  Copyright © 2015年 h.yamaguchi. All rights reserved.
//



#import "CardView.h"

@implementation CardView

- (instancetype)init {
    self = [super init];
    if (self) {
        [self setup];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup
{
    self.backgroundColor = [UIColor clearColor];
    //背景图片
    _backImage = [[UIImageView alloc]init];
    _backImage.backgroundColor = [UIColor clearColor];
    
    _backImage.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height );
    [self addSubview:_backImage];
    UIBezierPath *maskPath;
    maskPath = [UIBezierPath bezierPathWithRoundedRect:_backImage.bounds
                                     byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
                                           cornerRadii:CGSizeMake(7.0, 7.0)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = _backImage.bounds;
    maskLayer.path = maskPath.CGPath;
    _backImage.layer.mask = maskLayer;

    //头像
    _imageView = [[UIImageView alloc]init];
//    _imageView.backgroundColor = [UIColor orangeColor];
    _imageView.frame = CGRectMake(self.frame.size.width/4, self.frame.size.height /4 , 200, 200);
    
    
//    _imageView.center = self.center;
    [_backImage addSubview:_imageView];

    //左
        _leftImage = [[UIImageView alloc]init];
//        _leftImage.backgroundColor = [UIColor orangeColor];
        _leftImage.frame = CGRectMake(0, self.frame.size.height/2.5, 20, 50);
        [_backImage addSubview:_leftImage];

    //右
        _rightImage = [[UIImageView alloc]init];
//        _rightImage.backgroundColor = [UIColor orangeColor];
        _rightImage.frame = CGRectMake(self.frame.size.width-20, self.frame.size.height/2.5, 20, 50);
        [_backImage addSubview:_rightImage];

    //选择
    _selectedView = [[UIView alloc]init];
    _selectedView.frame = _imageView.frame;
    _selectedView.backgroundColor = [UIColor clearColor];
    _selectedView.alpha = 0.0;
    [_backImage addSubview:_selectedView];
    //小字
    _label = [[UILabel alloc]init];
    _label.backgroundColor = [UIColor clearColor];
    _label.frame = CGRectMake(10, self.frame.size.height * 0.8, self.frame.size.width - 20, self.frame.size.height * 0.2);
    _label.font = [UIFont fontWithName:@"Futura-Medium" size:14];
    _label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_label];
    //主题
    _itemLable = [[UILabel alloc]init];
    _itemLable.backgroundColor = [UIColor clearColor];
    _itemLable.frame = CGRectMake(10, self.frame.size.height * 0.8 - 20, self.frame.size.width - 20, self.frame.size.height * 0.2);
    _itemLable.font = [UIFont fontWithName:@"Futura-Medium" size:20];
    _itemLable.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_itemLable];
}

@end

